"use strict";
const common_vendor = require("../../../common/vendor.js");
const api_evaluation_index = require("../../../api/evaluation/index.js");
const utils_tools = require("../../../utils/tools.js");
const config_app = require("../../../config/app.js");
if (!Array) {
  const _easycom_up_tabs2 = common_vendor.resolveComponent("up-tabs");
  const _easycom_up_rate2 = common_vendor.resolveComponent("up-rate");
  const _easycom_up_album2 = common_vendor.resolveComponent("up-album");
  const _easycom_up_empty2 = common_vendor.resolveComponent("up-empty");
  const _easycom_up_gap2 = common_vendor.resolveComponent("up-gap");
  const _easycom_up_toast2 = common_vendor.resolveComponent("up-toast");
  (_easycom_up_tabs2 + _easycom_up_rate2 + _easycom_up_album2 + _easycom_up_empty2 + _easycom_up_gap2 + _easycom_up_toast2)();
}
const _easycom_up_tabs = () => "../../../node-modules/uview-plus/components/u-tabs/u-tabs.js";
const _easycom_up_rate = () => "../../../node-modules/uview-plus/components/u-rate/u-rate.js";
const _easycom_up_album = () => "../../../node-modules/uview-plus/components/u-album/u-album.js";
const _easycom_up_empty = () => "../../../node-modules/uview-plus/components/u-empty/u-empty.js";
const _easycom_up_gap = () => "../../../node-modules/uview-plus/components/u-gap/u-gap.js";
const _easycom_up_toast = () => "../../../node-modules/uview-plus/components/u-toast/u-toast.js";
if (!Math) {
  (_easycom_up_tabs + _easycom_up_rate + _easycom_up_album + _easycom_up_empty + _easycom_up_gap + _easycom_up_toast)();
}
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  __name: "detail",
  setup(__props) {
    const uToastRef = common_vendor.ref(null);
    const data = common_vendor.reactive({
      queryParam: {
        pageNum: 1,
        pageSize: 10,
        communityId: void 0,
        scoreStar: "",
        type: void 0,
        // 0按月 1按年
        yearMonth: void 0
      },
      tabs: [
        { name: "全部" },
        { name: "满意" },
        { name: "一般" },
        { name: "不满意" }
      ],
      list: [],
      total: 0
    });
    const { queryParam, tabs, list, total } = common_vendor.toRefs(data);
    const current = common_vendor.ref(0);
    const onTypeItem = (item) => {
      current.value = item.index;
      switch (item.index) {
        case 0:
          queryParam.value.scoreStar = "";
          break;
        case 1:
          queryParam.value.scoreStar = 3;
          break;
        case 2:
          queryParam.value.scoreStar = 2;
          break;
        case 3:
          queryParam.value.scoreStar = 1;
          break;
      }
      list.value = [];
      total.value = 0;
      queryParam.value.pageNum = 1;
      getEvaluationList();
    };
    const getEvaluationList = () => {
      api_evaluation_index.listEvaluation(queryParam.value).then((res) => {
        const { data: data2 } = res;
        data2.records = data2.records ?? [];
        data2.records = arrProcess(data2.records);
        list.value = [...list.value, ...data2.records];
        total.value = data2.total;
      }).catch((err) => {
        uToastRef.value.show({
          type: "error",
          message: err
        });
      });
    };
    const arrProcess = (arr) => {
      if (arr.length) {
        arr = arr.map((item) => {
          let badgeNumberArr = [];
          let policeNameArr = [];
          if (item.badgeNumber && item.badgeNumber.includes("、")) {
            badgeNumberArr = item.badgeNumber.split("、");
          }
          if (item.policeName && item.policeName.includes("、")) {
            policeNameArr = item.policeName.split("、");
          }
          item.users = [];
          if (badgeNumberArr.length && policeNameArr.length) {
            policeNameArr.forEach((it, index) => {
              item.users.push(
                item.communityName + " " + it + " " + badgeNumberArr[index]
              );
            });
          } else {
            item.users.push(
              item.communityName + " " + item.policeName + " " + item.badgeNumber
            );
          }
          if (item.imgUrl) {
            item.imgUrl = item.imgUrl.split(",");
            if (item.imgUrl.length) {
              item.imgUrl = item.imgUrl.map((img) => {
                img = config_app.imgPrefix + img;
                return img;
              });
            }
          }
          return item;
        });
      }
      return arr;
    };
    common_vendor.onLoad((options) => {
      if (options && options.detailInfo) {
        let detailInfo = JSON.parse(options.detailInfo);
        queryParam.value.communityId = detailInfo.communityId;
        queryParam.value.type = options.type;
        queryParam.value.yearMonth = options.yearMonth;
        tabs.value[0].name = `全部（${detailInfo.cmySumCount}）`;
        tabs.value[1].name = `满意（${detailInfo.cmySatisfiedCount}）`;
        tabs.value[2].name = `一般（${detailInfo.cmyGeneralCount}）`;
        tabs.value[3].name = `不满意（${detailInfo.cmyDissatisfiedCount}）`;
        getEvaluationList();
      }
    });
    common_vendor.onReachBottom(() => {
      let allTotal = queryParam.value.pageNum * queryParam.value.pageSize;
      if (allTotal < total.value) {
        queryParam.value.pageNum++;
        getEvaluationList();
      } else {
        uToastRef.value.show({
          type: "info",
          message: "暂无更多数据"
        });
        return;
      }
    });
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.o(onTypeItem),
        b: common_vendor.p({
          list: common_vendor.unref(tabs),
          lineColor: "#0A8CFE",
          lineWidth: "70rpx",
          activeStyle: {
            color: "#0A8CFE",
            fontSize: "29rpx"
          },
          inactiveStyle: {
            color: "#000",
            fontSize: "29rpx"
          }
        }),
        c: common_vendor.unref(list).length
      }, common_vendor.unref(list).length ? {
        d: common_vendor.f(common_vendor.unref(list), (item, index, i0) => {
          return common_vendor.e({
            a: common_vendor.t(item.itemName),
            b: "5a89a10d-1-" + i0,
            c: common_vendor.o(($event) => item.scoreStar = $event, index),
            d: common_vendor.p({
              inactiveColor: "#CCCCCC",
              activeColor: "#F55300",
              size: "21",
              count: "3",
              readonly: true,
              modelValue: item.scoreStar
            }),
            e: common_vendor.t(item.scoreStar == 1 ? "不满意" : item.scoreStar == 2 ? "一般" : item.scoreStar == 3 ? "满意" : ""),
            f: common_vendor.t(item.content),
            g: item.imgUrl && item.imgUrl.length
          }, item.imgUrl && item.imgUrl.length ? {
            h: "5a89a10d-2-" + i0,
            i: common_vendor.p({
              urls: item.imgUrl,
              space: "20rpx",
              singleSize: "155rpx",
              multipleSize: "155rpx",
              autoWrap: true,
              maxCount: 3,
              unit: "rpx"
            })
          } : {}, {
            j: common_vendor.t(item.users.join("、")),
            k: common_vendor.t(item.appraiseUserName),
            l: common_vendor.t(common_vendor.unref(utils_tools.EncryptTel)(item.phonenumber)),
            m: common_vendor.t(item.createTime ? common_vendor.unref(common_vendor.dayjs)(item.createTime).format("YYYY-MM-DD hh:mm:ss") : ""),
            n: index
          });
        })
      } : {
        e: common_vendor.p({
          mode: "data",
          text: "暂无记录",
          icon: "http://cdn.uviewui.com/uview/empty/data.png"
        })
      }, {
        f: common_vendor.p({
          height: "1"
        }),
        g: common_vendor.sr(uToastRef, "5a89a10d-5", {
          "k": "uToastRef"
        })
      });
    };
  }
});
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-5a89a10d"]]);
wx.createPage(MiniProgramPage);
